data segment
    arry dw 9, 0, -25, -36, 9
    count equ ($ - arry) / 2
data ends
stack_segment segment
    dw 15 dup(?)
    tos label word
stack_segment ends
code segment
    assume cs: code, ds: data, ss: stack_segment
output_number proc near
    mov bp, sp
    pushf
    push ax
    push bx
    push cx
    push dx
    push bp
    mov cx, [bp+2]
    cmp cx, 0
    jge positive
    mov dl, '-'
    mov ah, 2
    int 21h
    neg cx
positive:
    mov bx, 10
    mov bp, sp
calculate_each:
    mov dx, 0
    mov ax, cx
    div bx
    add dx, '0'
    push dx
    mov cx, ax
    test cx, 0ffffh
    jne calculate_each
    mov ah, 2
output:
    cmp bp, sp
    je output_end
    pop dx
    int 21h
    jmp output
output_end:
    mov ah, 2
    mov dx, ' '
    int 21h
    pop bp
    pop dx
    pop cx
    pop bx
    pop ax
    popf
    ret
output_number endp
output_numbers macro
    local output_result
    mov si, count * 2
    mov di, 0
    mov dx, 9
    output_result:
        push [arry + di]
        call output_number
        pop bx
        int 21h
        add di, 2
        cmp di, si
        jne output_result
endm
start:
mov ax, data
mov ds, ax
mov ax, stack_segment
mov ss, ax
mov cx, count - 1
mov ah, 2
output_numbers
mov dx, 10
int 21h
bubble_outer:
    mov si, count
    sub si, cx
    shl si, 1
    mov di, count - 1
    shl di, 1
    bubble_inner:
        mov bx, [arry + di - 2]
        mov dx, [arry + di]
        cmp bx, dx
        jle continue
        mov [arry + di], bx
        mov [arry + di - 2], dx
    continue:
        cmp di, si
        je break
        sub di, 2
        jmp bubble_inner
    break:
    loop bubble_outer
output_numbers
mov ax, 4c00h
int 21h
code ends
end start